<!--回弹业务数据字典---回弹仪器设备管理---查看-->
<template>
  <div class="department" id="department">
    <!-- 右侧 -->
    <div class="department_right">
      <!-- 顶部导航栏 -->
      <div class="mechanism_nav">
        <!-- 左侧 -->
        <div class="mechanism_nav_left">
          <el-radio-group v-model="radio" size="small" @change="modelType($event)">
            <el-radio-button label="待办"></el-radio-button>
            <el-radio-button label="已办"></el-radio-button>
            <!-- #2b5a9d -->
          </el-radio-group>
        </div>
        <!-- 顶部按钮 -->
        <div class="print">
          <div class="printTable">
            <el-button type="primary" icon="el-icon-refresh" size="small" @click="yj_searchForm(getList)"></el-button>
            <el-button type="primary" icon="el-icon-circle-plus-outline" size="small"
              v-if="getList.modelType == '0' && yj_add == true" @click="edit('新增')">新增</el-button>
            <el-button type="primary" icon="el-icon-edit" size="small" v-if="getList.modelType == '0' && yj_edit == true"
              @click="edit('编辑')">编辑</el-button>

            <el-button type="primary" icon="el-icon-circle-check" size="small"
              v-if="getList.modelType == '0' && yj_send == true" @click="SubmitText(fId)">下发</el-button>
            <el-button type="primary" icon="el-icon-document-checked" size="small"
              v-if="getList.modelType == '0' && yj_receive == true" @click="edit('签收')">签收</el-button>
            <el-button type="primary" icon="el-icon-delete" size="small"
              v-if="getList.modelType == '0' && yj_delete == true" @click="rowDelete(fId)">删除</el-button>
          </div>
        </div>
      </div>

      <!-- 表格 -->
      <div class="text_table">
        <tableData :height="navigatepageNums > 1 ? 'calc(100% - 50px)' : '100%'" :config="table_config"
          :dataList="tableData" :loading="loading" @selection-change="selectionChange" @sort-change="sortChange"
          @click-change="rowChange" @ClickOnLine="yj_viewForm" :page="getList.page" :pageSize="getList.pageSize" />
        <pagination v-if="navigatepageNums > 1" :info="queryCriteriaData" :treelength="treelength"
          :total="queryCriteriaData.total" :pageNum.sync="getList.page" :limit.sync="getList.pageSize"
          @pagination="yj_searchForm(getList)" />
      </div>
      <!--配合比通知单编号弹框 查看 -->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog :title="dialogTitle" :modal-append-to-body="false" v-dialogDrag :visible.sync="dialogEditVisible"
          v-loading="loadingEditDialog" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: '650px' }" style="overflow: hidden">
            <div style="overflow-y: auto; margin-bottom: 20px">
              <div class="baseTitle">质量巡查信息</div>
              <div class="publicForm" style="height: 285px">
                <publicForm ref="publicForm0" lableWidth="115px" :formObj="formObjShow" :formData="formData"
                  @selectChange="selectChange" @inputChange="inputChange" @inputFocus="inputFocus"
                  :timestamp="formData.fPatrolfileurl" :fileList="fHandlefileList" @delteFile="delteFile">
                </publicForm>
              </div>

              <div class="baseTitle" v-if="Sign == '签收' || Sign == '查看'">
           
                巡查信息签收
              </div>
              <div class="publicForm" v-if="Sign == '签收' || Sign == '查看'" style="height: 80px">
                <publicForm ref="publicForm1" lableWidth="115px" :formObj="examineShow" :formData="formData"
                  @selectChange="selectChange" @inputChange="inputChange" @inputFocus="inputFocus">
                </publicForm>
              </div>
              <div style="height: 50px"></div>
            </div>
          </div>
          <div class="newlyAdded_btn" v-if="btnShow">
            <el-button type="primary" v-if="Sign == '新增' || Sign == '编辑'" @click="yj_saveForm('保存')">保存</el-button>
            <el-button type="primary" v-if="Sign == '签收'" @click="yj_saveForm('签收')">保存</el-button>

            <el-button type="warning" @click="dialogEditVisible = false">关闭</el-button>
          </div>
        </el-dialog>
      </div>
      <!--机构树 -->
      <div class="Control-1 mechanism_dialogS closure treeData" id="department1">
        <el-dialog title="机构树" :modal-append-to-body="false" v-dialogDrag :visible.sync="dialogEditVisibleTree"
          v-loading="loadingEditDialogTree" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: '650px' }" style="overflow: hidden">
            <div style="overflow-y: auto; margin-bottom: 50px; height: 100%">
              <tree style="height: 100%" :treeData="treeData" :checkData="checkData" nodeKey="fCompanyid"
                @getTreeInfo="handleNodeClick" :defaultProps="defaultProps">
              </tree>
            </div>
          </div>
          <div class="newlyAdded_btn">
            <el-button type="primary" @click="yj_saveForm('树')">保存</el-button>

            <el-button type="warning" @click="dialogEditVisibleTree = false">关闭</el-button>
          </div>
        </el-dialog>
      </div>
      <!-- 根据组织机构树选人---单选 -->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog :title="candidate" :modal-append-to-body="false" v-dialogDrag :visible.sync="dialogEditVisibleTree_p"
          v-loading="loadingEditDialogTree_p" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: '650px' }" style="overflow: hidden; width: 100%">
            <div style="margin-bottom: 20px; height: 100%; width: 100%">
              <div class="publicForm addMemberCheckBox" style="height: calc(100% - 40px); overflow-y: auto; width: 100%">
                <div class="addMemberCheckTree">
                  <div class="companyBox">
                    <el-tree :data="companyInfo" :props="defaultProps" @node-click="selectCompany"
                      :highlight-current="highlightBd"></el-tree>
                  </div>
                  <div class="departmentBox">
                    <div class="departmentTitle" v-for="(item, index) in departmentList" :key="index"
                      @click="seletDepartment(item, index)">
                      <a href="javascript:;" :class="num === item.fDepartmentId ? 'activetext' : ''"
                        :title="item.fShortName">
                        {{ item.fShortName }}</a>
                    </div>
                  </div>
                </div>

                <div class="addMemberCheckLeft">
                  <el-radio-group v-model="checkboxGroup1" @change="selectRealname($event, personList)">
                    <el-radio-button v-for="item in personList" :label="item.fUserid" :key="item.fUserid"
                      :value="item.fRealname">
                      <div class="addMemberCheck">
                        <div class="MemberIcon">
                          <img :src="item.fGender == 0 ? girls : boys" alt="" />
                        </div>
                        <div class="MemberDetailInfos">
                          <div class="name">{{ item.fRealname }}</div>
                          <div class="hostName">{{ item.fDepartmentName }}</div>
                          <div class="hostName">{{ item.fAccount }}</div>
                        </div>
                      </div>
                    </el-radio-button>
                  </el-radio-group>
                </div>
              </div>
            </div>
          </div>
          <div class="newlyAdded_btn" v-if="btnShow">
            <el-button type="primary" @click="submitMember(0)">保存</el-button>
            <el-button type="warning" @click="dialogEditVisibleTree_p = false">关闭</el-button>
          </div>
        </el-dialog>
      </div>

      <!-- 根据组织机构树选人---多选 -->
      <div class="Control-1 mechanism_dialogS closure">
        <el-dialog :title="candidate" :modal-append-to-body="false" v-dialogDrag :visible.sync="dialogEditVisibleTree_p2"
          v-loading="loadingEditDialogTree_p2" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
          element-loading-background="rgba(0, 0, 0, 0.2)">
          <div class="dialogBody common" :style="{ height: '650px' }" style="overflow: hidden; width: 100%">
            <div style="margin-bottom: 20px; height: 100%; width: 100%">
              <div class="publicForm addMemberCheckBox" style="height: calc(100% - 40px); overflow-y: auto; width: 100%">
                <div class="addMemberCheckTree">
                  <div class="companyBox">
                    <!-- <el-tree
                      :data="companyInfo"
                      :props="defaultProps"
                      @node-click="selectCompany"
                      :highlight-current="highlightBd"
                    ></el-tree> -->
                    <div class="companyBox_box" v-for="(item, index) in companyInfo" :key="index"
                      @click="selectCompanys(item, index)" :style="{
                        color: item.show === true ? '#fff' : '#555',
                        background:
                          item.show === true ? '#1559ba' : 'aliceblue',
                      }">
                      {{ item.fShortname }}
                    </div>
                  </div>
                  <div class="departmentBox">
                    <div class="departmentTitle" v-for="(item, index) in departmentList" :key="index"
                      @click="seletDepartment(item, index)">
                      <a href="javascript:;" :class="num === item.fDepartmentId ? 'activetext' : ''"
                        :title="item.fShortName">
                        {{ item.fShortName }}</a>
                    </div>
                  </div>
                </div>

                <div class="addMemberCheckLeft addMemberCheckLefts">
                  <el-checkbox-group v-model="checkboxGroup2" @change="selectRealname2($event, personList2)">
                    <el-checkbox-button v-for="item in personList2" :label="item.fUserid" :key="item.fUserid"
                      :value="item.fRealname">
                      <div class="addMemberCheck">
                        <div class="MemberIcon">
                          <img :src="item.fGender == 0 ? girls : boys" alt="" />
                        </div>
                        <div class="MemberDetailInfos">
                          <div class="name">{{ item.fRealname }}</div>
                          <div class="hostName">{{ item.fDepartmentName }}</div>
                          <div class="hostName">{{ item.fAccount }}</div>
                        </div>
                      </div>
                    </el-checkbox-button>
                  </el-checkbox-group>
                </div>

                <div class="selectPerson">
                  <div class="selectPersonTitle">
                    已选人员（{{ newData2.length }}人）
                  </div>
                  <div class="selectPersonData">
                    <div class="selectPersonDataBox" v-for="item in newData2" :label="item.fRealname"
                      :key="item.fRealname">
                      <div class="MemberIcon">
                        <img :src="item.fGender == 0 ? girls : boys" alt="" />
                      </div>
                      <div class="MemberDetailInfo1">
                        <div class="name">{{ item.fRealname }}</div>
                        <div class="hostName">{{ item.fDepartmentName }}</div>
                        <div class="hostName">{{ item.fAccount }}</div>
                      </div>
                      <div class="deleteUser" @click="deteleUser(item.fUserid)"></div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="newlyAdded_btn" v-if="btnShow">
            <el-button type="primary" @click="submitMember(1)">保存</el-button>
            <el-button type="warning" @click="dialogEditVisibleTree_p2 = false">关闭</el-button>
          </div>
        </el-dialog>
      </div>
    </div>
  </div>
</template>

<script>
import {
  getWorkProcessPatrol2PageLists, //主页面列表接口
  getWorkProcessPatrol2ByFid, //详情
  saveWorkProcessPatrol2, //保存
  saveWorkprocessPatrol2BySign, //签收
  deleteWorkProcessPatrol2, //删除
  commitWorkProcessPatrol2, //提交
  getBaseDepartmentUser, //调人员  同级
  getUserCompanyTreeList, //机构树
  getfQualitygridtype, //调被巡查项目
} from "@/api/request.js";

import tree from "@/components/siteQualityPage/QualityGridManage/tree"; //左侧机构树
import TableData from "@/components/stationProductionPage/HntManage/el-tables"; //主页面列表
import Pagination from "@/components/public/el-pagination"; //主页面分页
import publicForm from "@/components/public/el-form.vue"; //弹框form
import formJs from "../regexDetail.js"; //新增弹框配置项

export default {
  inject: ["reload"],
  name: "patrolInformationText",
  data() {
    return {
      name: "patrolInformationText",
      // 分页
      navigatepageNums: null, //是否显示分页
      queryCriteriaData: {},
      // 分页
      yj_view: null, //查看
      yj_add: null, //新增
      yj_edit: null, //编辑
      yj_delete: null, //删除
      yj_submit: null, //提交
      yj_send: null, //下发
      yj_receive: null, //签收
      yj_aduit: null, //审核
      radio: "待办",
      // 列表
      row: null,
      getList: {
        fCompanyid: "", // 左侧选中组织机构id
        fQualitygridclass: "", // 上方查询条件质量网格
        fQualitygridtype: "", // 上方查询条件工程网格
        fUnittype: "", //巡查单位类型（集团公司，分子公司，项目公司，监理单位）
        fStatus: "", //信息状态---编辑中（可编辑，可下发），待签收（可签收），执行中（可整改编辑），已结束
        warningLevel: "", // 预警状态 1：表示超期未结束 2：表示超期已结束
        page: 1, // 当前页码
        pageSize: 20, // 每页显示条数
        userId: "", // 查询待办或已办时传 列表页查询不传
        modelType: "0", // 0-待办 1-已办 传2 表示列表页查询
      },

      fId: null, //当前行数据fId
      loading: false, //列表转载
      table_config: formJs.table_configText,
      tableData: [], //表格列表数据列表
      // 列表

      // 弹框
      timeYMD: null, //当前日期
      btnShow: true,
      dialogTitle: "",
      loadingEditDialog: false, //弹框loading
      dialogEditVisible: false, //新增弹框是否显示
      formObjShow: formJs.formObj, //质量巡查信息
      formObj: formJs.formObj, //编辑
      formObjLook: formJs.formObjLook, //查看

      examineShow: formJs.examine, //巡查信息签收
      examine: formJs.examine, //编辑
      examineLook: formJs.examineLook, //查看

      Sign: "",
      projectUsersList: [], //项目部列表初始值
      formData: formJs.formData,
      saveData: null,
      fHandlefileList: [], //上传文件
      recordfiles: [], //删除文件
      // 弹框

      // 机构树
      dialogEditVisibleTree: false,
      loadingEditDialogTree: false,
      highlightBd: true, //左侧机构树停留背景色
      checked: true, //查看下级按钮
      companyTree: "", //所有数据
      treeData: [], //左侧树状图数据
      defaultProps: {
        children: "children",
        label: "fShortname",
      },
      checkData: [], //树状图默认选中id
      treeRow: null, //选中树数据
      // 机构树

      // 树选人
      dialogEditVisibleTree_p: false,
      loadingEditDialogTree_p: false,
      companyInfo: [], //公司树信息
      departmentList: [], //部门
      num: null,
      personList: [], //人员列表新增
      checkboxGroup1: [],
      boys: require("@/assets/img/organization/boys.png"),
      girls: require("@/assets/img/organization/girls.png"),
      newData: null,
      treeText: {
        companyId: null,
        userId: null,
        text: null,
      },
      propText: null,
      candidate: null,
      // 树选人--多选
      checkboxGroup2: [],
      dialogEditVisibleTree_p2: false,
      loadingEditDialogTree_p2: false,
      newData2: [],
      propText2: null,
      allUserInfo: [],
      userList: [],
      userListId: [],
      getUserInitialList: [], //抄送人初始列表
      personList2: [], //人员列表新增
      // 树选人--多选
      // 树选人

      userInfo: {}, //登录用户
    };
  },
  components: {
    TableData, //主页面列表
    Pagination, //分页
    publicForm, //表单
    tree, //树
  },
  created() {
    this.userInfo = JSON.parse(sessionStorage.getItem("yjSmart-userInfo"));
    // console.log("userInfo", this.userInfo);
  },
  mounted() {
    this.getList = {
      fCompanyid: this.userInfo.companyId, // 左侧选中组织机构id
      fQualitygridclass: "", // 上方查询条件质量网格
      fQualitygridtype: "", // 上方查询条件工程网格
      fUnittype: "", //巡查单位类型（集团公司，分子公司，项目公司，监理单位）
      fStatus: "", //信息状态---编辑中（可编辑，可下发），待签收（可签收），执行中（可整改编辑），已结束
      warningLevel: "", // 预警状态 1：表示超期未结束 2：表示超期已结束
      page: 1, // 当前页码
      pageSize: 20, // 每页显示条数
      userId: this.userInfo.userId, // 查询待办或已办时传 列表页查询不传
      modelType: "0", // 0-待办 1-已办 传2 表示列表页查询
    };
    this.getData();
    this.yj_searchForm(this.getList);
    this.btnRole(this.name);

    this.table_config.operation.cols = [
      {
        prop: "fStatus",
        type: "primary",
        handleRow: this.handleRow,
      },
    ];
    this.table_config.operation["specialClass"] = function (rowData) {
      var color = null;
      if (rowData == "待签收") {
        color = "red !important";
      } else if (rowData == "执行中") {
        color = "orange !important";
      } else if (rowData == "已结束") {
        color = "green !important";
      } else {
        color = "#409eff !important";
      }
      return color;
    };

    this.formObj[5].placeholder = "请先选择'被巡查项目'和'涉及质量网格类别'";
    this.formObj[5].options = [];
  },
  methods: {
    btnRole(name) {
      var btnList = [];
      var ModuleList = JSON.parse(sessionStorage.getItem("yjSmart-ModuleList"));
      if (ModuleList.length > 0) {
        ModuleList.map((item) => {
          if (item.fEncode == name) {
            btnList = item.modulebuttonList;
          }
        });
        var btnStr = [];
        btnList.map((item) => {
          btnStr.push(item.fEncode);
        });
        // this.yj_view = btnStr.includes("yj_view");
        this.yj_add = btnStr.includes("yj_add");
        this.yj_edit = btnStr.includes("yj_edit");
        this.yj_delete = btnStr.includes("yj_delete");
        // this.yj_submit = btnStr.includes("yj_submit");
        this.yj_send = btnStr.includes("yj_send");
        this.yj_receive = btnStr.includes("yj_receive");
        // this.yj_aduit = btnStr.includes("yj_aduit");
      } else {
        // this.yj_view = true;
        this.yj_add = true;
        this.yj_edit = true;
        this.yj_delete = true;
        // this.yj_submit = true;
        this.yj_send = true;
        this.yj_receive = true;
        // this.yj_aduit = true;
      }
    },
    modelType(e) {
      this.fId = "";
      if (e == "待办") {
        this.getList.modelType = "0";
        this.getList.fCompanyid = this.userInfo.companyId;
        this.getList.userId = this.userInfo.userId;
      } else {
        this.getList.fCompanyid = this.userInfo.companyId;
        this.getList.modelType = "1";
        this.getList.userId = this.userInfo.userId;
      }
      this.yj_searchForm(this.getList);
    },
    // 获取列表数据
    yj_searchForm(id) {
      this.loading = true;
      // getQualityDutyStationLists(id)
      getWorkProcessPatrol2PageLists(id)
        .then((res) => {
          if (res.errcode == 0) {
            var that = this;
            that.loading = false;
            that.tableData = res.data.pageInfo.list;
            that.queryCriteriaData = res.data.pageInfo;
            that.navigatepageNums =
              that.queryCriteriaData.navigatepageNums.length;
          } else {
            this.$message.error("列表", res.msg);
            this.loading = false;
          }
        })
        .catch(() => {
          console.log("列表");
          this.loading = false;
        });
    },
    // 新增/编辑/审核
    edit(titel) {
      0
      this.recordfiles = [];
      this.fHandlefileList = [];
      // 树选人
      this.newData = null;
      this.newData2 = [];
      this.checkboxGroup2 = [];
      // 树选人
      this.dialogTitle = titel;
      this.Sign = titel;
      this.formObjShow = this.formObj;
      this.btnShow = true;
      var companyNature = "";
      if (this.userInfo.companyNature == "集团公司") {
        companyNature = "集团公司";
      } else if (this.userInfo.companyNature == "分子公司") {
        companyNature = "分子公司";
      } else if (this.userInfo.companyNature == "建设单位") {
        companyNature = "项目公司";
      } else if (this.userInfo.companyNature == "总监办") {
        companyNature = "监理单位";
      } else {
        companyNature = "";
      }
      if (titel == "新增") {
        var timestamp = Date.now();
        this.dialogEditVisible = true;
        this.formData = {
          fId: "",
          fProjectid: this.userInfo.projectId, // 当前登录人项目ID
          fProjectname: this.userInfo.projectName, // 当前登录人项目名称
          fProjectfullname: "",
          fCompanyid: this.userInfo.companyId, // 当前登录人标段ID
          fCompanyname: this.userInfo.companyName, // 当前登录人标段名称
          fCompanyfullname: "",
          fUnittype: companyNature, //巡查单位类型
          fPatroldates: this.timeYMD, //巡查日期
          fUnitid: this.userInfo.companyId, //巡查单位id
          fUnit: this.userInfo.companyName, //巡查单位
          fPatrolproject: "", //被巡查项目
          fPatrolprojectid: "", //被巡查项目id
          fQualitygridclass: "", //涉及指令网格类别
          fQualitygridtype: "", //涉及工程网格类别
          fQualitygridtypeid: "", //涉及工程网格类别对应的Fid
          fIsredline: "是", //是否红线问题
          fPatrolname: "", //巡查人员姓名
          fPatroldescription: "", //巡查问题描述
          fCorrectiverequest: "", //整改要求
          fPatrolfileurl: "XCXC" + timestamp, //巡查过程资料
          fRequestcompletiondates: this.timeYMD, //要求整改完成日期
          fReportid: this.userInfo.userId, //填报人id
          fReportname: this.userInfo.realName, //填报人姓名
          fReportdates: this.timeYMD, //填报时间
          fSubsignid: "", //指定签收人id
          fSubsignname: "", //指定签收人姓名
          fCcpeople: "", //抄送人姓名数组
          fCcpeopleid: "", //抄送人id数组
          fSignstatus: "", //签收情况
          fSigndescription: "", //签收说明
          fSignid: "", //签收人id
          fSignname: "", //签收人姓名
          fSigndates: "", //签收时间
          fCompletionresult: "", //整改结果
          fCompletiondates: "", //整改完成日期
          fCompletiondescription: "", //整改内容概述
          fCompletionfile: "", //整改资料
          fCompletionleaderid: "", //整改负责人id
          fCompletionleader: "", //整改负责人姓名
          fCreateuserid: "",
          fCreateusername: "",
          fCreatedate: "",
          fCreatedates: "",
          fModifyuserid: "",
          fModifydate: "",
          fModifydates: "",
          fModifyusername: "",
          fStatus: "", //信息状态
          fNote: "",
        };
      } else if (titel == "编辑") {
        if (this.fId != "" && this.fId != null) {
          if (this.row.fStatus == "编辑中") {
            this.loadingEditDialog = true; //弹框loading
            this.dialogEditVisible = true;
            this.getConcrete(this.fId);
          } else {
            return this.$message.error("请选择信息状态为‘编辑中’的数据");
          }
        } else {
          return this.$message.error("请先选择需要编辑的数据");
        }
      } else if (titel == "签收") {
        if (this.fId != "" && this.fId != null) {
          if (this.row.fStatus == "待签收") {
            this.formObjShow = this.formObjLook;
            this.examineShow = this.examine;
            this.loadingEditDialog = true; //弹框loading
            this.dialogEditVisible = true;
            this.getConcrete(this.fId);
          } else {
            return this.$message.error("请选择信息状态为‘审核中’的数据");
          }
        } else {
          return this.$message.error("请先选择需要审核的数据");
        }
      }
    },
    // 获取详情
    getConcrete(id) {
      getWorkProcessPatrol2ByFid({ fId: id })
        .then((res) => {
          if (res.errcode == 0) {
            this.loadingEditDialog = false; //弹框loading

            this.formData = res.data.yjQmpMsWorkprocessPatrol;
            this.fHandlefileList = res.data.fPatrolfileurllist;
            if (this.Sign == "编辑") {
              //巡查单位类型
              if (
                this.formData.fUnittype == "" ||
                this.formData.fUnittype == null
              ) {
                var companyNature = "";
                if (this.userInfo.companyNature == "集团公司") {
                  companyNature = "集团公司";
                } else if (this.userInfo.companyNature == "分子公司") {
                  companyNature = "分子公司";
                } else if (this.userInfo.companyNature == "建设单位") {
                  companyNature = "项目公司";
                } else if (this.userInfo.companyNature == "总监办") {
                  companyNature = "监理单位";
                } else {
                  companyNature = "";
                }
                this.formData.fUnittype = companyNature; //巡查单位类型
              }
              //项目名称
              if (
                this.formData.fProjectname == "" ||
                this.formData.fProjectname == null ||
                this.formData.fProjectid == "" ||
                this.formData.fProjectid == null
              ) {
                this.formData.fProjectname = this.userInfo.projectName;
                this.formData.fProjectid = this.userInfo.projectId;
              }
              // 标段名称
              if (
                this.formData.fCompanyname == "" ||
                this.formData.fCompanyname == null ||
                this.formData.fCompanyid == "" ||
                this.formData.fCompanyid == null
              ) {
                this.formData.fCompanyname = this.userInfo.companyName;
                this.formData.fCompanyid = this.userInfo.companyId;
              }
              //巡查日期
              if (
                this.formData.fPatroldates == "" ||
                this.formData.fPatroldates == null
              ) {
                this.formData.fPatroldates = this.timeYMD; //巡查日期
              }
              // 巡查单位
              if (
                this.formData.fUnitid == "" ||
                this.formData.fUnitid == null ||
                this.formData.fUnit == "" ||
                this.formData.fUnit == null
              ) {
                this.formData.fUnit = this.userInfo.companyName; //巡查单位
                this.formData.fUnitid = this.userInfo.companyId; //巡查单位id
              }

              //要求整改完成日期
              if (
                this.formData.fRequestcompletiondates == "" ||
                this.formData.fRequestcompletiondates == null
              ) {
                this.formData.fRequestcompletiondates = this.timeYMD; //巡查日期
              }

              //填报人
              if (
                this.formData.fReportname == "" ||
                this.formData.fReportname == null ||
                this.formData.fReportid == "" ||
                this.formData.fReportid == null
              ) {
                this.formData.fReportname = this.userInfo.realName;
                this.formData.fReportid = this.userInfo.userId;
              }
              //填报日期
              if (
                this.formData.fReportdates == "" ||
                this.formData.fReportdates == null
              ) {
                this.formData.fReportdates = this.timeYMD;
              }
            } else if (this.Sign == "签收") {
              // 签收人
              if (
                this.formData.fSignname == "" ||
                this.formData.fSignname == null ||
                this.formData.fSignid == "" ||
                this.formData.fSignid == null
              ) {
                this.formData.fSignname = this.userInfo.realName;
                this.formData.fSignid = this.userInfo.userId;
              }

              //审核日期
              if (
                this.formData.fSigndates == "" ||
                this.formData.fSigndates == null
              ) {
                this.formData.fSigndates = this.timeYMD;
              }
            }
          } else {
            console.log("详情接口", res.errcode);
          }
        })
        .catch((err) => {
          console.log(err.msg);
        });
    },
    // 刪除文件
    delteFile(file) {
      for (let index = 0; index < this.fHandlefileList.length; index++) {
        if (file.uid == this.fHandlefileList[index].uid) {
          if (this.fHandlefileList[index].atta == undefined) {
            this.recordfiles.push({
              fId: this.fHandlefileList[index].fId,
            });
          } else {
            this.recordfiles.push({
              fId: this.fHandlefileList[index].atta.fId,
            });
          }
          this.fHandlefileList.splice(index, 1);
        }
      }
    },
    // 保存
    yj_saveForm(num) {
      console.log(num);
      if (num == "树") {
        console.log("选择树", this.treeRow);
        if (this.treeRow.fNature == "施工单位") {
          if (
            this.treeRow.fProjectname != null &&
            this.treeRow.fProjectname != ""
          ) {
            this.formData.fPatrolproject = this.treeRow.fShortname;
            // this.formData.fPatrolproject =
            //   this.treeRow.fProjectname + "-" + this.treeRow.fShortname;
          } else {
            this.formData.fPatrolproject = this.treeRow.fShortname;
          }
          this.formData.fPatrolprojectid = this.treeRow.fCompanyid;
          this.getPerson(this.treeRow.fCompanyid)

          this.dialogEditVisibleTree = false;
          if (
            this.formData.fQualitygridclass != "" &&
            this.formData.fQualitygridclass != null
          ) {
            var QualitygridtypeData1 = {
              fCompanyid: this.formData.fPatrolprojectid, // 查询条件项目名称id
              fQualitygridclass: this.formData.fQualitygridclass, //质量网格类别
            };
            this.getFQualitygridtype(QualitygridtypeData1);
          } else {
            this.formObj[5].placeholder =
              "请先选择'被巡查项目'和'涉及质量网格类别'";
            this.formObj[5].options = [];
          }
          this.formData.fSubsignid = '' //指定签收人id
          this.formData.fSubsignname = '' //指定签收人id
          this.formData.fCcpeople = ''
          this.formData.fCcpeopleid = ''
          this.formData.fQualitygridtype = ''

        } else {
          this.$message.warning("请选择施工单位");
        }
      } else if (num == "签收") {
        this.fId = "";
        if (this.$refs.publicForm1.submitForm()) {
          var saveData = {
            fId: this.formData.fId, //当前fid
            fSignstatus: this.formData.fSignstatus, //签收情况 (已签收)
            fSigndescription: this.formData.fSigndescription, //签收说明
            fSignid: this.formData.fSignid, //签收人id
            fSignname: this.formData.fSignname, //签收人姓名
            fSigndates: this.formData.fSigndates, //签收时间
          };
          saveWorkprocessPatrol2BySign(saveData)
            .then((res) => {
              if (res.errcode == 0) {
                this.yj_searchForm(this.getList);
                this.dialogEditVisible = false;
                this.$message.success("签收成功");
              } else {
                this.$message.error(res.msg);
                console.log("接口报错");
              }
            })
            .catch((error) => {
              console.log(error);
            });
        } else {
          console.log("error");
        }
      } else {
        this.fId = "";
        if (this.$refs.publicForm0.submitForm()) {
          if (this.fHandlefileList.length > 0) {
            this.saveData = {
              fId: this.formData.fId, //传fid代表修改 不传代表新增
              fProjectid: this.formData.fProjectid,
              fProjectname: this.formData.fProjectname,
              fProjectfullname: this.formData.fProjectfullname,
              fCompanyname: this.formData.fCompanyname,
              fCompanyid: this.formData.fCompanyid,
              fCompanyfullname: this.formData.fCompanyfullname,
              fUnittype: this.formData.fUnittype, //巡查单位类型
              fPatroldates: this.formData.fPatroldates, //巡查日期
              fUnit: this.formData.fUnit, //巡查单位
              fUnitid: this.formData.fUnitid, //巡查单位id
              fPatrolprojectid: this.formData.fPatrolprojectid, //被巡查项目id
              fPatrolproject: this.formData.fPatrolproject, //被巡查项目
              fQualitygridtype: this.formData.fQualitygridtype, //工程网格类别
              fQualitygridclass: this.formData.fQualitygridclass, //质量网格类别
              fQualitygridtypeid: this.formData.fQualitygridtypeid, //涉及工程网格类别对应的Fid
              fIsredline: this.formData.fIsredline, //是否红线问题
              fPatrolname: this.formData.fPatrolname, //巡查人员姓名
              fPatroldescription: this.formData.fPatroldescription, //巡查问题描述
              fCorrectiverequest: this.formData.fCorrectiverequest, //整改要求
              fPatrolfileurl: this.formData.fPatrolfileurl, //巡查过程资料
              fRequestcompletiondates: this.formData.fRequestcompletiondates, //要求整改完成日期
              fReportid: this.formData.fReportid, //填报人id
              fReportname: this.formData.fReportname, //填报人姓名
              fReportdates: this.formData.fReportdates, //填报日期
              fSubsignid: this.formData.fSubsignid, //指定签收人id
              fSubsignname: this.formData.fSubsignname, //指定签收人姓名
              fCcpeople: this.formData.fCcpeople, //抄送人姓名数组
              fCcpeopleid: this.formData.fCcpeopleid, //抄送人id数组
              userId: this.userInfo.userId,
              userName: this.userInfo.realName,
              recordfiles: this.recordfiles,
            };
            saveWorkProcessPatrol2(this.saveData)
              .then((res) => {
                if (res.errcode == 0) {
                  this.yj_searchForm(this.getList);
                  this.dialogEditVisible = false;
                  this.$message.success("新增成功");
                } else {
                  this.$message.error(res.msg);
                  console.log("接口报错");
                }
              })
              .catch((error) => {
                console.log(error);
              });
          } else {
            this.$message.warning("请上传巡查过程资料");
          }
        } else {
          console.log("error");
        }
      }
    },
    getPerson(data) {
      var obj = {
        fCompanyid: data,
      };
      getBaseDepartmentUser(obj)
        .then((res) => {
          if (res.errcode == 0) {

            var arr = res.data.childList[0].personList;
            //工作计划信息新增options
            // formObj
            var personList = [];
            arr.map((item) => {
              personList.push({
                label: item.fRealname,
                value: item.fUserid,
              });
            });
            // console.log(55655, personList);
            this.formObj[14].options = personList;

            // this.formObj[10].options = personList;
            // this.formObj[11].options = personList;
            // this.formFinishObj[6].options = personList;
            // this.formFinishObj[7].options = personList;
          } else {
            this.$message.error(res.msg);
            return false;
          }
        })
        .catch((error) => {
          console.log(error);
        });
    },
    // 下发
    SubmitText(id) {
      if (id != "" && id != null) {
        if (this.row.fStatus == "编辑中") {
          this.$confirm("是否继续下发?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.loading = true;
              commitWorkProcessPatrol2({
                fId: id,
                userId: this.userInfo.userId,
                userName: this.userInfo.realName,
              })
                .then((res) => {
                  if (res.errcode == 0) {
                    this.loading = false;
                    this.yj_searchForm(this.getList);
                    this.$message.success("下发成功");
                  } else {
                    this.$message.error("下发失败", res.msg);
                    this.loading = false;
                  }
                })
                .catch(() => {
                  console.log("下发失败");
                  this.loading = false;
                });
            })
            .catch(() => {
              this.$message.info("取消下发");
            });
        } else {
          return this.$message.error("请选择状态为'编辑中'的数据");
        }
      } else {
        return this.$message.error("请先选择需要提交的数据");
      }
    },

    // 删除
    rowDelete(id) {
      if (id != "" && id != null) {
        if (this.row.fStatus == "编辑中") {
          this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          })
            .then(() => {
              this.loading = true;
              deleteWorkProcessPatrol2({ fId: id })
                .then((res) => {
                  if (res.errcode == 0) {
                    this.loading = false;
                    this.yj_searchForm(this.getList);
                    this.$message.success("删除成功");
                  } else {
                    this.$message.error("删除失败", res.msg);
                    this.loading = false;
                  }
                })
                .catch(() => {
                  console.log("删除失败");
                  this.loading = false;
                });
            })
            .catch(() => {
              this.$message("取消删除");
            });
        } else {
          return this.$message.error("请选择状态为'编辑中'的数据");
        }
      } else {
        return this.$message.error("请先选择需要删除的数据");
      }
    },

    // 点击查看
    yj_viewForm(row, label) {
      this.fId = row.fId;
      if (label == "巡查单位") {
        this.editText(this.fId);
      }
    },

    // 查看
    editText(id) {
      this.formObjShow = this.formObjLook;
      this.examineShow = this.examineLook;
      this.dialogTitle = "查看";
      this.Sign = "查看";
      this.btnShow = false;
      if (id != "" && id != null) {
        this.loadingEditDialog = true; //弹框loading
        this.dialogEditVisible = true;
        // getQualityDutyStationByFid({ fId: id })
        getWorkProcessPatrol2ByFid({ fId: id })
          .then((res) => {
            if (res.errcode == 0) {
              this.loadingEditDialog = false; //弹框loading
              this.formData = res.data.yjQmpMsWorkprocessPatrol;
              this.fHandlefileList = res.data.fPatrolfileurllist;
              // this.fCompletionfilelist = res.data.fCompletionfilelist;
            } else {
              this.$message.error("查看", res.msg);
              this.loadingEditDialog = false;
            }
          })
          .catch(() => {
            console.log("查看---详情接口报错");
            this.loadingEditDialog = false;
          });
      } else {
        return this.$message.error("请先选择需要查看的数据");
      }
    },
    getFQualitygridtype(data) {
      getfQualitygridtype(data)
        .then((res) => {
          if (res.errcode == 0) {
            this.formObj[5].placeholder = "请选择";
            this.formObj[5].options = [];
            var Qualitygridtype = {
              value: "",
              label: "",
            };
            res.data.fQualitygridtypelist.map((item) => {
              Qualitygridtype = {
                value: item,
                label: item,
              };
              this.formObj[5].options.push(Qualitygridtype);
            });
            console.log("999999", this.formObj[5].options);
          } else {
            this.$message.error(res.msg);
            this.loadingEditDialog = false;
          }
        })
        .catch(() => {
          console.log("查看---详情接口报错");
          this.loadingEditDialog = false;
        });
    },
    selectChange(value, index, prop) {
      // console.log("下拉变", value, index, prop);
      //巡查单位类型
      if (prop == "fUnittype" && index == 0 && value == "==单位类型==") {
        this.formData.fUnittype = "";
      }

      // 工程网格下拉框
      if (prop == "fQualitygridclass" && index == 4) {
        this.formData.fQualitygridtype = ''
        if (value == "生产场站质量网格") {

          if (
            this.formData.fPatrolprojectid != "" &&
            this.formData.fPatrolprojectid != null
          ) {
            var QualitygridtypeData1 = {
              fCompanyid: this.formData.fPatrolprojectid, // 查询条件项目名称id
              fQualitygridclass: value, //质量网格类别
            };
            this.getFQualitygridtype(QualitygridtypeData1);
          } else {
            this.formObj[5].placeholder =
              "请先选择'被巡查项目'和'涉及质量网格类别'";
            this.formObj[5].options = [];
          }
          // this.formObj[5].placeholder = "请选择";
          // this.formObj[5].options = [
          //   {
          //     value: "混凝土拌合站",
          //     label: "混凝土拌合站",
          //   },
          //   {
          //     value: "水稳料拌合站",
          //     label: "水稳料拌合站",
          //   },
          //   {
          //     value: "沥青料拌合站",
          //     label: "沥青料拌合站",
          //   },
          //   {
          //     value: "钢筋加工场",
          //     label: "钢筋加工场",
          //   },
          //   {
          //     value: "梁板预制场",
          //     label: "梁板预制场",
          //   },
          //   {
          //     value: "碎石材料加工厂",
          //     label: "碎石材料加工厂",
          //   },
          //   {
          //     value: "小型预制构件厂",
          //     label: "小型预制构件厂",
          //   },
          // ];
        } else if (value == "工程实体质量网格") {
          if (
            this.formData.fPatrolprojectid != "" &&
            this.formData.fPatrolprojectid != null
          ) {
            var QualitygridtypeData2 = {
              fCompanyid: this.formData.fPatrolprojectid, // 查询条件项目名称id
              fQualitygridclass: value, //质量网格类别
            };
            this.getFQualitygridtype(QualitygridtypeData2);
          } else {
            this.formObj[5].placeholder =
              "请先选择'被巡查项目'和'涉及质量网格类别'";
            this.formObj[5].options = [];
          }

          // this.formObj[5].placeholder = "请选择";
          // this.formObj[5].options = [
          //   {
          //     value: "路基土石方",
          //     label: "路基土石方",
          //   },
          //   {
          //     value: "路面工程",
          //     label: "路面工程",
          //   },
          //   {
          //     value: "桥梁工程",
          //     label: "桥梁工程",
          //   },
          //   {
          //     value: "隧道工程",
          //     label: "隧道工程",
          //   },
          //   {
          //     value: "涵洞工程",
          //     label: "涵洞工程",
          //   },
          //   {
          //     value: "防护排水",
          //     label: "防护排水",
          //   },
          //   {
          //     value: "交安工程",
          //     label: "交安工程",
          //   },
          //   {
          //     value: "管道工程",
          //     label: "管道工程",
          //   },
          //   {
          //     value: "房建工程",
          //     label: "房建工程",
          //   },
          //   {
          //     value: "绿化工程",
          //     label: "绿化工程",
          //   },
          // ];
        } else if (value == "/") {
          this.formObj[5].placeholder = "请选择";
          this.formObj[5].options = [
            {
              value: "/",
              label: "/",
            },
          ];
          this.formData.fQualitygridtype = "/";
        } else {
          this.formObj[5].placeholder = "请先选择涉及质量网格类别";
          this.formObj[5].options = [];
        }
      }
      if (prop == "fSubsignname") {
        this.formData.fSubsignid = value.value
        this.formData.fSubsignname = value.label
      }
    },

    inputChange(value, index, prop) {
      // console.log("input变", value, index, prop);
      return value, index, prop;
    },
    inputFocus(index, prop) {
      this.propText = prop;
      // console.log("input获焦", index, prop);
      if (this.dialogTitle != "新增") {
        this.newData = [];
        this.checkboxGroup1 = [];
        this.newData2 = [];
        this.checkboxGroup2 = [];
      }
      if (prop == "fPatrolproject") {
        this.getTree(this.formData.fCompanyid);
      }
      if (prop == "fSubsignname") {
        if (
          this.formData.fPatrolproject == "" ||
          this.formData.fPatrolproject == null
        ) {
          this.$message.error("请先选择被巡查项目");
        } else {
          this.candidate = "选择指定签收人";
          this.treeText.companyId = this.formData.fPatrolprojectid;
          this.treeText.userId = this.formData.fPatrolproject;
          this.getBaseCompanyList(this.treeText, prop);
        }
      }
      if (prop == "fCcpeople") {
        if (
          this.formData.fPatrolproject == "" ||
          this.formData.fPatrolproject == null
        ) {
          this.$message.error("请先选择被巡查项目");
        } else {
          this.getUserInitialList = []; //人员列表初始值
          this.candidate = "选择抄送人";
          this.treeText.companyId = this.formData.fPatrolprojectid;
          this.treeText.userId = this.formData.fPatrolproject;
          this.getBaseCompanyList(this.treeText, prop);
        }
      }
    },

    getData() {
      var time = new Date();
      const y = time.getFullYear();
      const m = (time.getMonth() + 1 + "").padStart(2, "0");
      const d = (time.getDate() + "").padStart(2, "0");
      this.timeYMD = `${y}-${m}-${d}`;
    },
    // 点击当前
    rowChange(val) {
      this.row = val;
      this.fId = val.fId;
    },

    // 多选方法
    selectionChange() { },
    // 排序方法
    sortChange() { },

    //弹框--- 树结构
    getTree(id) {
      var treeText = {
        companyId: id,
        userId: this.userInfo.userId,
      };
      this.loadingEditDialogTree = true;
      getUserCompanyTreeList(treeText)
        .then((res) => {
          if (res.errcode == 0) {
            this.dialogEditVisibleTree = true;
            this.loadingEditDialogTree = false;
            var companyTree = res.data.userCompanyTreeList;
            this.treeData = this.commonJs.tranListToTreeData(companyTree);

            if (
              this.formData.fPatrolprojectid != "" &&
              this.formData.fPatrolprojectid != null
            ) {
              this.checkData[0] = this.formData.fPatrolprojectid;
            }
          } else {
            this.$message.error(res.msg);
            this.loadingEditDialogTree = false;
            // this.$message.error("获取组织机构失败");
            return false;
          }
        })
        .catch(() => {
          this.loadingEditDialogTree = false;
          return false;
        });
    },
    handleNodeClick(data) {
      this.treeRow = data;
    },
    //弹框--- 树结构

    // 树选人
    // 树结构
    getBaseCompanyList(data, prop) {
      this.departmentList = [];

      this.num = null;
      if (prop == "fSubsignname") {
        // 单选
        this.personList = [];
        this.departmentList = [];
        this.dialogEditVisibleTree_p = true;
        this.loadingEditDialogTree_p = true;

        getUserCompanyTreeList(data)
          .then((res) => {
            this.loadingEditDialogTree_p = false;
            // this.loadingEditDialogTree_p2 = false;
            if (res.errcode == 0) {
              this.companyInfo = this.commonJs.tranListToTreeData(
                res.data.userCompanyTreeList
              );
              // 全部人员
              // if (this.propText == "fCcpeople") {
              res.data.userCompanyTreeList.map((item) => {
                this.getUser(item.fCompanyid);
              });
              // }
              // 全部人员
            } else {
              this.$message.error("获取组织机构单位", res.msg);
            }
          })
          .catch((error) => {
            console.log("获取组织机构单位,接口报错", error);
          });
      } else if (prop == "fCcpeople") {
        // 多选
        let companyInfoList = [];
        var flag = true;
        this.companyInfo = [];
        this.personList2 = [];
        this.dialogEditVisibleTree_p2 = true;
        // this.loadingEditDialogTree_p2 = true;
        if (
          this.formData.fUnitid != "" &&
          this.formData.fUnitid != null &&
          this.formData.fUnit != "" &&
          this.formData.fUnit != null
        ) {
          companyInfoList.push({
            fCompanyid: this.formData.fUnitid,
            fShortname: this.formData.fUnit,
          });
        }

        if (
          this.formData.fPatrolprojectid != "" &&
          this.formData.fPatrolprojectid != null &&
          this.formData.fPatrolproject != "" &&
          this.formData.fPatrolproject != null
        ) {
          companyInfoList.push({
            fCompanyid: this.formData.fPatrolprojectid,
            fShortname: this.formData.fPatrolproject,
          });
        }
        // 去重
        for (let index = 0; index < companyInfoList.length; index++) {
          flag = true;
          for (let y = 0; y < this.companyInfo.length; y++) {
            if (
              this.companyInfo[y].fCompanyid ==
              companyInfoList[index].fCompanyid
            ) {
              flag = false;
            }
          }
          if (flag) {
            this.companyInfo.push(companyInfoList[index]);
          }
        }
        // 去重

        // console.log("companyInfo", this.companyInfo);

        // 全部人员
        this.companyInfo.map((item) => {
          this.getUser(item.fCompanyid);
        });
        // 全部人员
      }
    },

    //根据树  调部门
    selectCompany(e) {
      this.departmentList = [];
      this.personList = []; //单选
      // this.personList2 = []; //多选

      this.num = null;
      this.getBaseDepartmentUserFun(e.fCompanyid);
    },
    selectCompanys(e, index) {
      for (let i in this.companyInfo) {
        if (parseFloat(i) === index) {
          this.companyInfo[i].show = true;
        } else {
          this.companyInfo[i].show = false;
        }
      }
      this.departmentList = [];
      // this.personList = []; //单选
      this.personList2 = []; //多选

      this.num = null;
      this.getBaseDepartmentUserFun(e.fCompanyid);
    },

    // 部门管理-查询部门列表以及下属人员
    getBaseDepartmentUserFun(id) {
      getBaseDepartmentUser({ fCompanyid: id })
        .then((res) => {
          if (res.errcode == 0) {
            this.departmentList = res.data.childList;
          } else {
            this.$message.error("部门管理-查询部门列表以及下属人员", res.msg);
          }
        })
        .catch((error) => {
          console.log("部门管理-查询部门列表以及下属人员,接口报错", error);
        });
    },
    // 选择部门
    seletDepartment(e) {
      this.num = e.fDepartmentId;
      let obj = {};
      if (this.propText == "fSubsignname") {
        // 单选
        this.personList = [];
        this.personList = e.personList.reduce(function (item, next) {
          //item为没有重复id的数组，next为当前对象
          obj[next.fUserid]
            ? ""
            : (obj[next.fUserid] = true && item.push(next));
          return item;
        }, []);
        // 处理选人回填--单选
        if (
          this.propText == "fSubsignname" &&
          this.formData.fSubsignname != "" &&
          this.formData.fSubsignname != null
        ) {
          this.personList.map((item) => {
            if (this.formData.fSubsignid == item.fUserid) {
              this.newData = item;
              this.checkboxGroup1 = item.fUserid;
            }
          });
        }
        // 处理选人回填--单选
      } else if (this.propText == "fCcpeople") {
        // 多选
        this.personList2 = [];
        this.personList2 = e.personList.reduce(function (item, next) {
          //item为没有重复id的数组，next为当前对象
          obj[next.fUserid]
            ? ""
            : (obj[next.fUserid] = true && item.push(next));
          return item;
        }, []);
      }
    },
    // 单选--选人
    selectRealname(e, data) {
      data.map((item) => {
        if (e == item.fUserid) {
          this.newData = item;
        }
      });
    },
    // 多选--选人
    selectRealname2(e, data) {
      this.allUserInfo = this.allUserInfo.concat(data);
      let obj = {};
      let reduce = [];
      reduce = this.allUserInfo.reduce((item, next) => {
        //item为没有重复id的数组，next为当前对象
        obj[next.fUserid] ? "" : (obj[next.fUserid] = true && item.push(next));
        return item;
      }, []);

      this.newData2 = [];
      reduce.map((item) => {
        this.checkboxGroup2.map((i) => {
          if (item.fUserid == i) {
            this.newData2.push(item);
          }
        });
      });
    },
    // 删除用户--多选
    deteleUser(id) {
      this.newData2 = this.newData2.filter((item) => {
        return item.fUserid != id;
      });
      this.checkboxGroup2 = this.checkboxGroup2.filter((item) => {
        return item != id;
      });
    },
    // 保存
    submitMember(num) {
      if (num == 0) {
        // 单选
        if (this.propText == "fSubsignname") {
          this.formData.fSubsignid = this.newData.fUserid;
          this.formData.fSubsignname = this.newData.fRealname;
        }
        this.dialogEditVisibleTree_p = false;
      } else if (num == 1) {
        // 多选
        if (this.propText == "fCcpeople") {
          this.userList = [];
          this.userListId = [];
          this.newData2.map((item) => {
            this.userList.push(item.fRealname);
            this.userListId.push(item.fUserid);
          });

          this.formData.fCcpeople = this.userList.join(","); //抄送人姓名集合
          this.formData.fCcpeopleid = this.userListId.join(","); //抄送人id集合
        }
        this.dialogEditVisibleTree_p2 = false;
      }
    },

    // 全部人--多选
    getUser(id) {
      getBaseDepartmentUser({ fCompanyid: id })
        .then((res) => {
          if (res.errcode == 0) {
            res.data.childList.map((v) => {
              v.personList.map((item) => {
                this.getUserInitialList.push(item);
              });
            });
            // 处理选人回填--多选
            if (
              this.propText == "fCcpeople" &&
              this.formData.fCcpeople != "" &&
              this.formData.fCcpeople != null
            ) {
              this.newData2 = [];
              this.checkboxGroup2 = [];
              this.allUserInfo = [];

              this.getUserInitialList.map((item) => {
                this.formData.fCcpeopleid.split(",").map((v) => {
                  if (v == item.fUserid) {
                    this.newData2.push(item);
                    this.checkboxGroup2.push(item.fUserid);
                    this.allUserInfo.push(item);
                  }
                });
              });
            }
            // 处理选人回填--多选
          } else {
            this.$message.error(res.msg);
            console.log("部门管理-查询部门列表以及下属人员,接口报错");
          }
        })
        .catch((error) => {
          console.log("部门管理-查询部门列表以及下属人员", error);
        });
    },
    // 树选人
  },
};
</script>

<style scoped lang="less">
.printTables {
  background: #fff;
  display: flex;
  justify-content: end;
  padding: 5px;
  margin-top: 10px;
}

.dialogBody {
  padding: 3px 20px;
  height: 80%;
  overflow-y: auto;
}

.baseTitle {
  /* border: 1px solid #0c204d; */
  border-bottom: 1px solid #0c204d;
  height: 30px;
  line-height: 30px;
  position: relative;
  padding-left: 15px;
}

.baseTitle::after {
  display: block;
  content: "";
  height: 30px;
  width: 5px;
  position: absolute;
  left: 0;
  top: 0;
  background: #0c204d;
}

/* 弹框 */

.mouldForm /deep/ .el-col-12 .el-form-item:first-child .el-input__suffix {
  left: 84% !important;
}

.publicForm .mouldForm /deep/ .el-form-item__content {
  margin-left: 120px !important;
}

/* 弹框 */

/* 树选人 */
.addMemberCheckBox /deep/ .el-tree {
  overflow: hidden;
}

.addMemberCheckBox {
  display: flex;

  .addMemberCheckTree {
    width: 30%;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(221, 221, 221, 1);
    box-sizing: border-box;

    .companyBox {
      height: 70%;
      box-sizing: border-box;
      overflow-y: auto;

      // 自己生成
      .companyBox_box {
        color: #555;
        width: 100%;
        height: 30px;
        line-height: 30px;
        background: aliceblue;
        border-radius: 28px 0 0 28px;
        font-size: 12px !important;
        font-weight: 700 !important;
        padding-left: 30px;
      }

      // 自己生成
    }

    .departmentBox {
      height: 30%;
      border-top: 0.5px solid rgba(221, 221, 221, 1);
      /* border: 1px solid red; */
      display: flex;
      flex-wrap: wrap;
      align-content: flex-start;
      overflow: hidden;
      overflow-y: auto;

      .departmentTitle {
        width: 77px;
        text-align: center;
        height: 40px;
        margin: 5px;
        // border: 1px solid green;
        border-radius: 8px;
        background: #d4daea;
        overflow: hidden;

        a {
          width: 100%;
          height: 100%;
          display: block;
          text-decoration: none;
        }
      }
    }
  }

  .selectMemberLeft {
    display: flex;
    align-items: center;
  }

  .addMemberCheckLeft {
    width: 70%;
    padding: 0 0 0 20px;
    border-top: 1px solid rgba(221, 221, 221, 1);
    border-bottom: 1px solid rgba(221, 221, 221, 1);
    border-right: 1px solid rgba(221, 221, 221, 1);

    .addMemberCheck {
      width: 150px;
      height: 64px;
      border-radius: 2px;
      display: flex;
      align-items: center;
      position: absolute;
      top: 0;
      left: 0;
    }
  }

  .addMemberCheckLefts {
    width: 52%;
  }
}

.newlyAdded_btns {
  height: 8%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}

.addMemberCheck .MemberIcon {
  height: 62px;
  width: 64px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(241, 241, 241, 1);
}

.MemberIcon img {
  width: 37.81px;
  height: 39.38px;
  border-radius: 50%;
}

.MemberDetailInfos {
  position: relative;
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;

  .name {
    color: rgba(51, 51, 51, 1);
    font-size: 12px;
    height: 20px;
    line-height: 20px;
  }

  .hostName {
    color: rgba(128, 125, 125, 1);
    font-size: 12px;
    height: 20px;
    line-height: 20px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.MemberIcon .name {
  color: rgba(51, 51, 51, 1);
  font-size: 12px;
  height: 20px;
  line-height: 20px;
}

.MemberIcon .hostName {
  color: rgba(128, 125, 125, 1);
  font-size: 12px;
  height: 20px;
  line-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activetext {
  color: rgba(197, 227, 255, 1);
  background: #2b5a9d;
}

// 多选人
.addMemberCheckBox .selectPerson {
  width: 18%;
  display: flex;
  flex-direction: column;
  border: 1px solid rgba(221, 221, 221, 1);
  margin-left: 15px;
  box-sizing: border-box;

  .selectPersonTitle {
    height: 28px;
    line-height: 28px;
    text-align: center;
    background: rgba(241, 241, 241, 1);
    border-bottom: 1px solid rgba(221, 221, 221, 1);
    color: rgba(128, 125, 125, 1);
    font-size: 12px;
  }

  .selectPersonData {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;

    .selectPersonDataBox {
      width: 165px;
      height: 72px;
      border-radius: 2px;
      border: 1px solid rgba(222, 222, 222, 1);
      margin: 8px 0;
      display: flex;
      position: relative;

      .MemberIcon {
        height: 100%;
        width: 64px;
        display: flex;
        justify-content: center;
        align-items: center;
        margin-right: 8px;
        background: rgba(241, 241, 241, 1);

        img {
          width: 37.81px;
          height: 39.38px;
          border-radius: 50%;
        }
      }

      .MemberDetailInfo1 {
        position: relative;
        flex: 1;
        height: 100%;
        padding: 14px 0;
        overflow: hidden;

        .name {
          color: rgba(51, 51, 51, 1);
          font-size: 12px;
          height: 20px;
          line-height: 5px;
          white-space: nowrap;
        }

        .hostName {
          color: rgba(128, 125, 125, 1);
          font-size: 12px;
          height: 20px;
          line-height: 10px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
      }
    }
  }
}

.MemberDetailInfo::after {
  position: absolute;
  width: 30px;
  height: 30px;
  display: block;
  background: url("../../../../../assets/img/organization/yes.png") no-repeat;
  background-size: 100% 100%;
  right: 0;
  top: 0;
}

.deleteUser {
  position: absolute;
  width: 22px;
  height: 22px;
  display: block;
  background: url("../../../../../assets/img/organization/no.png") no-repeat;
  background-size: 100% 100%;
  right: 0;
  top: 0;
}

// 多选人

.samllDialogs {
  display: flex;
  margin: 0 20px;
  padding-top: 50px;

  .treeModule {
    flex: 1;
  }
}

.addMemberCheckLeft /deep/ .el-radio-button {
  display: inline-block;
  width: 150px;
  height: 64px;
  position: relative;
  margin: 8px;
  border-radius: 2px;
  overflow: hidden;
  /* border: 1px solid rgba(222, 222, 222, 1); */
}

.addMemberCheckLeft /deep/ .el-radio-button__inner {
  border: 1px solid rgba(222, 222, 222, 1);
  border-radius: 2px;
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
}

.addMemberCheckLeft /deep/ .el-radio-group {
  flex-wrap: wrap;
  font-size: 0;
  display: flex;
  /* flex-direction: column; */
}

/* 树选人 */

// 树弹框
#department1 /deep/ .el-dialog {
  width: 600px !important;
}

// 树弹框
</style>